#include "network/basic.h"

#include <winsock2.h>

#include "base/result_codes.h"
#include "network/result_codes.h"

namespace network {

int Init() {
#ifdef _WIN32
    WSAData wsa_data;

    if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != 0) {
        // TODO(patrick): WSAGetLastError can get more detailed information,
        // which we may want to log or return.
        return ER_INIT_FAILED;
    }
#endif // _WIN32

    return base::OK_OK;
}

int Cleanup() {
#ifdef _WIN32
    if (WSACleanup() != 0) {
        // TODO(patrick): WSAGetLastError can get more detailed information,
        // which we may want to log or return.
        return ER_CLEANUP_FAILED;
    }
#endif // _WIN32

    return base::OK_OK;
}

} // namespace network
